//
//  HMCaseManageCollectionCell.m
//  仿真开发
//
//  Created by B.HOPE on 2017/3/26.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "HMCaseManageCollectionCell.h"
#import <Masonry.h>

@interface HMCaseManageCollectionCell ()

@property (nonatomic, strong) UIButton *deleBtn;

@property (nonatomic, strong) UIImageView *imgView;


@end

@implementation HMCaseManageCollectionCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    _imgView = [[UIImageView alloc] init];
    _imgView.image = [UIImage imageNamed:@"compose_pic_add_highlighted"];
    [self.contentView addSubview:_imgView];
    [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.equalTo(self);
        make.top.offset(10);
        make.right.offset(-10);
    }];
    
    _deleBtn = [[UIButton alloc] init];
    [_deleBtn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    [self.contentView addSubview:_deleBtn];
    _deleBtn.hidden = YES;
    [_deleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.equalTo(self);
        make.size.mas_offset(CGSizeMake(10, 10));
    }];
    
    [_deleBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clickBtn:(UIButton *)sender
{
    _imgView.image = [UIImage imageNamed:@"compose_pic_add_highlighted"];
//    _imgView.hidden = YES;
    
    _deleBtn.hidden = YES;
}




- (void)setIcon:(UIImage *)icon
{
    _icon = icon;
    
    if (icon == nil)
    {
        return;
    }
    
    _imgView.image = icon;
    _deleBtn.hidden = NO;
}

@end
